home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11497 < prev    next >
Encoding:
Text File  |  1996-08-05  |  3.6 KB  |  99 lines

  1. Path: melbpc.org.au!juanjose
  2. From: juanjose@melbpc.org.au (Juan Suarez)
  3. Newsgroups: comp.lang.c++
  4. Subject: Automatic  Data Segm exceeds 64 K
  5. Date: Thu, 14 Mar 1996 08:46:19 UTC+10
  6. Organization: Melbourne PC User Group, Australia
  7. Message-ID: <juanjose.74.002CFB27@melbpc.org.au>
  8. NNTP-Posting-Host: dialup-84.melbpc.org.au
  9. Summary: Error in BC++ 3.5  (automatic data segm exceeds 64K)
  10. Keywords: C++ segment problems
  11. X-Newsreader: Trumpet for Windows [Version 1.0 Rev B final beta #4]
  12.  
  13. hI!
  14. If you have a solution for this problem, please send me a few lines with 
  15. indications. I am not a C programmer, and in a program I am having errors 
  16. like:"Linker Error: Automatic data segment exceeds 64K" or some times "A1 
  17. overlaps ... DGROUP ..."
  18. I am using Borland C++ v3.5 as compiler...
  19.  
  20. I sumarize the problem, in the next 2 samples of code.. They are just a summary extracted from the DLL source, (without the LibMain & WEP and etc etc).
  21.  
  22. Sample of SOURCE FILE MYINCLUDE.H:
  23. ----------------------------------
  24.   ......
  25.   extern "C" int FAR PASCAL _export allocmem (void);
  26.   extern "C" int FAR PASCAL _export movmem(void);
  27.  
  28.   HANDLE   hptr[500];                            //hndl to allocmem
  29.   char far *ttt[500];                            //pointer to allocated memory
  30.   .....
  31. int FAR PASCAL allocmem (void)
  32. {
  33.     extern HANDLE hptr[90]; 
  34.     extern char far  * ttt[90] ;
  35.     int ii;
  36.  
  37.     for (ii=0;ii<500;ii++)
  38.     {
  39.        hptr[ii] = GlobalAlloc(0x0000 , 200);
  40.        if(hptr[ii]==NULL) goto wrong;
  41.        ttt[ii]=(char *) GlobalLock(hptr[ii]);
  42.     }
  43. wrong:
  44.     return ii;
  45. }
  46.  
  47. Sample of SOURCE FILE EXAMPL1.CPP:
  48. ----------------------------------
  49.  
  50. #include <windows.h>
  51. // #pragma codeseg movmem  "movmem" movmem  <-- comented out (did not work)
  52.  
  53. int FAR PASCAL movmem(void)
  54. {
  55.         extern    char far *ttt[500] ; 
  56.  
  57.     char vectA0[195]="1234567890 1234567890 1234567890 1234567890";
  58.     char vectA1[195]="1234567890 1234567890 1234567890 1234567890";
  59.       //... similars senteces ommited....
  60.     char vectA88[195]="1234567890 1234567890 1234567890 1234567890";
  61.     char vectA89[195]="1234567890 1234567890 1234567890 1234567890";
  62.  
  63.     hmemcpy(ttt[0],vectA0[0],190);
  64.     hmemcpy(ttt[1],vectA1[0],190);
  65.      //.. simmilars sentences ommited ...
  66.     hmemcpy(ttt[88],vectA88[0],190);
  67.     hmemcpy(ttt[89],vectA89[0],190);
  68.    return 1;
  69. }
  70.  
  71.  
  72. This did work fine, till I included more functions simmilars to 'movmem', trying
  73. to fill the rest of the allocated memory with required data.
  74. Then the KRNL386.EXE couldn't even start the DLL..
  75.  
  76. To visualize the problem I modified a simple windows example (whello.cpp) to 
  77. include in it similar code. And the KRNL386.EXE abended in the same address
  78. 0001:73C3... So I try differents ways to solve the problem.
  79. I did spread these new routines in different new source files, trying to avoid linking limitations. But all I tried failed. Even renaming segments and
  80. groups in the 'project ide' options.. (Borland C++ 3.5), or inserting 
  81. #pragma codeseg <"segm_name"> <group> , also did not lead me to solve the
  82. problem. 
  83. I guess all is explained in the error message of the linker, when I compiled my modified "whello.cpp". I added into it, 2 sources (SRCFILE1.CPP & SRCFILE2.CPP) with routines similars to the 'movmem' above. The messages were:
  84.  
  85. Compiling WHELLO.CPP:
  86. Compiling whello.rc:
  87. Compiling SRCFILE1.CPP:
  88. Compiling SRCFILE2.CPP:
  89. Linking whello.exe:
  90. Linker Error: Automatic data segment exceeds 64K
  91.  
  92. Please send me a few lines abut this... Thank you again.
  93. Juan Jose.
  94. e-mail: juanjose@melbpc.org.au        
  95.   ,-._|\    Juan Jose Suarez       E-Mail: juanjose@melbpc.org.au    
  96.  /  Oz  \   7/94 Beach Rd.         Melbourne - 3194 - Australia
  97.  \_,--._/   ph: (03)9584-2620      MelbPC User Group
  98.          
  99.